package com.example.demo.service.impl;

import com.example.demo.dao.DupnewDao;
import com.example.demo.entity.Dupnew;
import com.example.demo.service.DupnewService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (Dupnew)表服务实现类
 *
 * @author makejava
 * @since 2022-02-15 14:04:38
 */
@Service("dupnewService")
public class DupnewServiceImpl implements DupnewService {
    @Resource
    private DupnewDao dupnewDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Dupnew queryById(Integer id) {
        return this.dupnewDao.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param dupnew 实例对象
     * @return 实例对象
     */
    @Override
    public Dupnew insert(Dupnew dupnew) {
        this.dupnewDao.insert(dupnew);
        return dupnew;
    }

    /**
     * 修改数据
     *
     * @param dupnew 实例对象
     * @return 实例对象
     */
    @Override
    public Dupnew update(Dupnew dupnew) {
        this.dupnewDao.update(dupnew);
        return this.queryById(dupnew.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.dupnewDao.deleteById(id) > 0;
    }
}
